package java05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;

public class DouDiZhu {
	public static void main(String[] args) {
		TreeMap<Integer,String> treeMap = new TreeMap<Integer, String>();
		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		treeMap.put(0, "大王");
		treeMap.put(1, "小王");
		int num=2;
		for(String number:numbers){
			for(String color:colors){
				treeMap.put(num, color+number);
				num++;
			}
		}
		Set<Integer> keySet = treeMap.keySet();
		List<Integer> keyList = new ArrayList<>(keySet); 
		
		Collections.shuffle(keyList);
		Player p1=new Player();p1.setName("老王");
		Player p2=new Player();p2.setName("老李");
		Player p3=new Player();p3.setName("老刘");
		ArrayList<Integer> dipai=new ArrayList<Integer>();
		
		for(int i=0;i<keyList.size();i++){
			Integer p=keyList.get(i);
			if(i>=51){
				dipai.add(p);
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		Collections.sort(p1.getPoker(),new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o1-o2;
			}
		});
		Collections.sort(p2.getPoker(),new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o1-o2;
			}
		});
		Collections.sort(p3.getPoker(),new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o1-o2;
			}
		});
		System.out.print(p1.getName()+":");
		show(treeMap,p1.getPoker());
		System.out.print(p2.getName()+":");
		show(treeMap,p2.getPoker());
		System.out.print(p3.getName()+":");
		show(treeMap,p3.getPoker());
		System.out.print("底牌：");
		show(treeMap,dipai);
	}
	public static void show(TreeMap<Integer,String> map,ArrayList<Integer> list){
		for(Integer i:list){
			System.out.print(map.get(i)+" ");
		}
		System.out.println("");
	}
}
